using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using RecruitmentSystem.Business;
using RecruitmentSystem.Common;

public partial class CheckUserNameAvailable : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["username"] != "" && Request.QueryString["username"] != null)
            {
                string username = Request.QueryString["username"];
                string usertype = Request.QueryString["usertype"];
                Response.Write(IsRegistered(username, usertype));
            }
        }
    }

    private string IsRegistered(string username,string utype)
    {
        string resultStr = "UnRegister";
        AccountManager am = new AccountManager();
        bool isReg = false;
        if (utype == "1")
        {
            isReg = am.CheckUserId(username, UserType.EnterpriseUser);
        }
        else if (utype == "2")
        {
            isReg = am.CheckUserId(username, UserType.PersonalUser);
        }
        else if (utype == "3")
        {
            isReg = am.CheckUserId(username, UserType.SchoolUser);
        }
        if (isReg)
        {
            resultStr = "Registered";
        }
        return resultStr;
    }
}
